package com.glsc.ngateway.platform.service.itflow.flowstrategy.cmdb.partStandardModify.taskPostHandler;

import com.glsc.ngateway.common.api.flowable.dto.task.doTaskParam.cmdb.CMDBPassParamDto;
import com.glsc.ngateway.common.api.flowable.dto.task.formData.cmdb.PartStandardModifyTaskFormDto;
import com.glsc.ngateway.common.api.flowable.dto.task.formData.cmdb.domainDto.FlowFormPartStandardModifyDto;
import com.glsc.ngateway.common.base.enums.itflow.ITFlowTaskEnum;
import com.glsc.ngateway.common.base.repo.mysql.gateway.platform.flow.cmdb.FlowFormPartStandardModifyRepo;
import com.glsc.ngateway.platform.service.itflow.flowstrategy.cmdb.partStandardModify.PartStandardModifyFlowStrategy;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.validation.constraints.NotNull;

/**
 * @author zhengyr
 * @date 2023/8/2-16:16
 * 发起人确认节点
 */
@Component
public class PSMStep2ConfirmTaskPostHandlerAudit implements IPartStandardModifyTaskPostHandlerAudit {

    @Autowired
    PSMStepHandlerHelper handlerHelper;
    @Autowired
    PartStandardModifyFlowStrategy partStandardModifyFlowStrategy;
    @Autowired
    FlowFormPartStandardModifyRepo flowFormPartStandardModifyRepo;

    @Override
    public String getTaskDefinitionKey() {
        return ITFlowTaskEnum.CMDB_PART_STANDARD_MODIFY_FLOW_CREATOR_AUDIT_TASK.getTaskKey();
    }
    @Override
    public void passAfterHandle(@NotNull CMDBPassParamDto<FlowFormPartStandardModifyDto, PartStandardModifyTaskFormDto> passParam, @NotNull String operator) throws Exception {
        //确认节点通过后邮件抄送给上级领导，更新配件库数据
        handlerHelper.endTaskAfterHandle(passParam, operator);
        //更新配件库数据
        handlerHelper.updatePartStandard(passParam.getProcessId(),operator);
    }

}
